var pixelProjection = new ol.proj.Projection({
    code: 'pixel',
    units: 'pixels',
    extent: [0, 0, 1024, 968]
});
var map = new ol.Map({
    target : 'map',
    layers : [
        new ol.layer.Tile({
            source: new ol.source.Stamen({
                layer: 'watercolor'
            })
        }),
        new ol.layer.Image({
            source: new ol.source.ImageStatic({
                attributions: [
                    new ol.Attribution({
                        html: '&copy; <a href="http://xkcd.com/license.html">xkcd</a>'
                    })
                ],
                url: '../static/image/demo.png',
                imageSize: [1024, 968],
                projection: pixelProjection,
                imageExtent: pixelProjection.getExtent()
            })
        })
    ],
    view: new ol.View({
        //需要注意的是 'EPSG:4326', 'EPSG:3857'  由于我在分号之间打了空格 导致代码执行出错，切记！
        //projection: pixelProjection,
        //center: ol.extent.getCenter(pixelProjection.getExtent()),
        center: ol.proj.transform([37.41, 8.82], 'EPSG:4326', 'EPSG:3857'),
        zoom: 4
    })
});

//添加比例尺，单位m
var scaleLineControl = new ol.control.ScaleLine();
scaleLineControl.setUnits(ol.control.ScaleLineUnits.METRIC);
map.addControl(scaleLineControl);
//缩放工具条
var zoomSilder = new ol.control.ZoomSlider();
map.addControl(zoomSilder);